#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
/*
题目描述：

*/
long long N,M;
long long tree[1000000];
long long H,lowest,highest,midH,totalH;  //最终的高度
int main()
{
    cin >> N >> M;
    long long i;
    for(i=0;i<N;i++)
    {
        cin >> tree[i];
    }

    sort(tree, tree+N);
    lowest = tree[0];
    highest = tree[N-1];
    midH = (lowest+highest)/2;

    while(lowest < highest)
    {
        totalH = 0;
        for(i=0;i<N;i++)
        {
            if(tree[i]>midH)
                totalH += tree[i]-midH;
        }
        if(totalH=M)
            H = midH;
        if(totalH<M) //现在的总长比较小，所以需要降低砍树高度，以获取更多的木材
        {
            highest = midH-1;
        }
        else
        {
            lowest = midH+1;
        }
        midH = (lowest+highest)/2;
    }

    cout << midH;

    return 0;
}